---
category: DOM
created: '2020-04-19'
title: Get all siblings of an element
updated: '2021-10-13'
---

**JavaScript version**

```js siblings.js
const siblings = (ele) => [].slice.call(ele.parentNode.children).filter((child) => child !== ele);
```

**TypeScript version**

```ts siblings.ts
const siblings = (ele: Node): Node[] =>
    ele.parentNode ? [].slice.call(ele.parentNode.children).filter((child) => child !== ele) : [];
```
